feat(harness): per-worktree setup/teardown lifecycle hooks (#9) - #29
Closed
robercano-ghbot wants to merge 1 commit into
Closed
feat(harness): per-worktree setup/teardown lifecycle hooks (#9)#29robercano-ghbot wants to merge 1 commit into
robercano-ghbot wants to merge 1 commit into
Conversation
Isolated implementer/reviewer worktrees lack toolchain state that lives outside
the tree (node_modules, Foundry libs from `forge install`, shared caches), so some
gates could only run in the main checkout — defeating in-worktree gating. Adds an
optional per-worktree lifecycle to the adapter so "every gate runs in isolation"
becomes actually true.
- .claude/scripts/worktree.sh — gate.sh-style runner for `setup`/`teardown`, reads
.worktree.<phase> from the adapter, honors GATES_FILE, skips when empty, exits 2
on a bad phase. Resolves root from its own location so inside a worktree it
installs into that worktree.
- .claude/gates.json + .claude/self/gates.json — new "worktree" block ({setup,
teardown}) documenting the hook; self ships both empty (node/bash-only gates).
- implementer.md — new step 1 "Bootstrap your worktree" (run worktree.sh setup
before exploring), teardown after opening the PR; subsequent steps renumbered.
- test-runner.md — run worktree.sh setup first when gating a fresh worktree.
Docs (GETTING_STARTED/USAGE) coverage of the hook is a module:docs follow-up, kept
out of this harness-only slice. Self gates build+lint+test green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011HosUeuSvhetARboEfDW6K
robercano
approved these changes
Jul 1, 2026
Collaborator
Author
robercano-ghbot
pushed a commit
that referenced
this pull request
Jul 2, 2026
Rebased onto current main to resolve the conflict on .claude/agents/implementer.md that blocked the approved PR #29 (its branch was cut from a stale base). Content is identical to #29 — merged cleanly onto main: keeps the GitHub-identity + explicit-staging rules already on main and layers the worktree bootstrap step + teardown + renumbering. - .claude/scripts/worktree.sh — gate.sh-style setup/teardown runner (GATES_FILE-aware). - .claude/gates.json + .claude/self/gates.json — new "worktree" {setup,teardown} block. - implementer.md — step 1 bootstrap + teardown after PR; steps renumbered. - test-runner.md — run worktree.sh setup first when gating a fresh worktree. Supersedes #29. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011HosUeuSvhetARboEfDW6K
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional per-worktree lifecycle to the adapter so isolated implementer/reviewer worktrees can bootstrap toolchain state that lives outside the tree —
node_modules, Foundry libs fromforge install, shared caches — making "every gate runs in isolation" actually true instead of some gates only being runnable in the main checkout.How
.claude/scripts/worktree.sh(new) — agate.sh-style runner:worktree.sh setup|teardownreads.worktree.<phase>from the adapter, honorsGATES_FILE, resolves the repo root from its own location (so inside a worktree it installs into that worktree), skips cleanly (exit 0) when empty/unconfigured, exits 2 on an invalid phase, and propagates a non-zero hook exit so a failed bootstrap surfaces..claude/gates.json+.claude/self/gates.json— new"worktree": { setup, teardown }block documenting the hook. Self ships both empty (node/bash-only gates need no external state).implementer.md— new step 1 "Bootstrap your worktree" (runworktree.sh setupbefore exploring), teardown after opening the PR; remaining steps renumbered 2–7.test-runner.md— runworktree.sh setupfirst when gating a fresh worktree.Scope
Harness-module slice of #9 (adapter
.claude/self/gates.json, moduleharness=.claude/). All 5 files under.claude/. Docs coverage (GETTING_STARTED/USAGE) of the hook is amodule:docsfollow-up, deliberately kept out of this harness-only PR.Gates & review
GATES_FILE=.claude/self/gates.jsonbuild + lint + test green. Runner exercised across its input space: skip→0, invalid-phase→2, no-arg→usage error, configured hook runs, failing hook propagates its code, GATES_FILE relative/absolute both resolve.Reviewer lenses per self-adapter (correctness, tests), consensus=all: both approved (high confidence). Two cosmetic nits raised were confirmed to intentionally mirror
gate.sh's existing convention (no-arg exit 1;basenamein the skip message) — left as-is for consistency with the sibling script.Closes #9.
🤖 Generated with Claude Code